#include "Interpolation.hpp"
#include "Function.hpp"
#include <iostream>
#include <vector>
class F1 : public Function {
public:
    double operator() (double x) const{
        return x;
    }
};
int main() {
    // 定义一组插值点
    std::vector<double> xVec = {1, 2, 3, 4, 5};
    std::vector<double> yVec;

    F1 f1;
     for (size_t i = 0; i < xVec.size(); ++i) {
        yVec.push_back(f1(xVec[i]));
    }

    // 创建牛顿插值对象
    NewtonInterpolation interpolation(xVec, yVec);

    // 测试插值的几个点
    std::vector<double> testPoints = {1.5, 2.5, 3.5, 4.5};
    std::cout << "牛顿插值测试结果：" << std::endl;
    for (double x : testPoints) {
        std::vector<double> result = interpolation.interpolate(x);
        std::cout << "插值点 x = " << x << " 的插值结果为: " << result[0] << std::endl;
    }


     std::vector<std::vector<double>> data = {
        {1, 2, 3}, // x values
        {1, 4, 9}, // f(x) values
        {2, 4, 6}  // f'(x) values
    };
    
    HermiteInterpolation interpolator(data);
    std::vector<double> result = interpolator.interpolate(4);
    std::cout << "Interpolated value at x = 4: " << result[0] << std::endl;

    std::vector<std::vector<double>> controlPoints = {
        {1,1}, // 第一个控制点
        {2,2}, // 第二个控制点
        {3,3},
        {4,4}
    };
    BezierInterpolation bezier(controlPoints);

    // 计算t=0.5时的曲线点
    double t = 0.5;
    std::vector<double> point = bezier.interpolate(t);

    std::cout << "Bezier curve point at t = " << t << " is (" << point[0] << ", " << point[1] << ")" << std::endl;

    return 0;
}